import { uploadType } from '@/utils/util'
import apiMod from '@/apiMod/index'

export const formConfig = {
	inline: false,
	showBtn: true,
	labelPosition: 'top',
	labelWidth: '120px',
	column: [
		{
			label: '补贴类别名称',
			prop: 'subsidyName',
			maxlength: '50',
			showWordLimit: true,
			type: 'text',
			span: 12,
			rules: [{ required: true, message: '请输入补贴类别名称' }],
		},
		{
			label: '补贴金额（元）',
			prop: 'money',
			type: 'number',
			min: 0,
			controlsPosition: 'right',
			span: 12,
			rules: [{ required: true, message: '请输入补贴金额（元）' }],
		},
		{
			label: '是否达标统计',
			prop: 'isStandard',
			type: 'select',
			dicData: [
				{
					label: '是',
					value: 0,
				},
				{
					label: '不是',
					value: 1,
				},
			],
			rules: [{ required: true, message: '请选择是否达标统计' }],
			span: 12,
		},
		{
			label: '状态是否启用',
			prop: 'ruleStatus',
			type: 'select',
			dicData: [
				{
					label: '启用',
					value: 0,
				},
				{
					label: '不启用',
					value: 1,
				},
			],
			rules: [{ required: true, message: '请选择状态是否启用' }],
			span: 12,
		},
		{
			type: 'DividerHtml',
			modelValue: '服务对象补贴类别设置',
			prop: 'contactHtml',
			labelPosition: 'top',
			position: 'center',
			span: 24,
		},
		{
			label: '',
			type: 'dynamic',
			prop: 'omSubsidyTypeOldmanPOList',
			span: 24,
			changeField: true,
			custome: 'table',
			column: [
				{
					label: '服务对象类别',
					prop: 'elderlyType',
					propName: 'elderlyTypeLabel',
					type: 'remoteSelect',
					code: 'ELDERLY_TYPE',
					api: 'getDictItemList',
					filterKey: 'value',
					multiple: false,
					showLabel: false,
					span: 8,
				},
				{
					label: '能力等级',
					prop: 'elderlyLevel',
					propName: 'elderlyLevelLabel',
					type: 'remoteSelect',
					code: 'ACCESS_LEVEL_COUNTRY',
					api: 'getDictItemList',
					filterKey: 'value',
					multiple: false,
					showLabel: false,
					span: 8,
				},
				{
					label: '最小年龄',
					prop: 'minAge',
					type: 'input',
					span: 8,
				},
				{
					label: '最大年龄',
					prop: 'maxAge',
					type: 'input',
					span: 8,
				},
				{
					label: '是否失智',
					prop: 'isDementia',
					type: 'select',
          custome:'tag',
					dicData: [
						{ label: '失智', value: 1 },
						{ label: '不失智', value: 0 },
					],
					span: 8,
				},
			],
		},
		{
			type: 'DividerHtml',
			modelValue: '服务标准设置',
			prop: 'contactHtml',
			labelPosition: 'top',
			position: 'center',
			span: 24,
		},
		{
			label: '',
			type: 'dynamic',
			prop: 'omServiceStandardPOList',
			span: 24,
			changeField: true,
			custome: 'table',
			column: [
				{
					label: '选择标准',
					prop: 'serviceCycle',
					type: 'select',
					custome: 'tag',
					dicData: [
						{ label: '天', value: 1 },
						{ label: '周', value: 2 },
						{ label: '月', value: 3 },
						{ label: '季度', value: 4 },
						{ label: '半年', value: 5 },
						{ label: '年', value: 6 },
					],
					span: 8,
				},
				{
					label: '服务天数（天）',
					prop: 'serviceDays',
					type: 'number',
					min: 0,
					controlsPosition: 'right',
					span: 8,
				},
				{
					label: '服务总时间（分钟）',
					prop: 'serviceTime',
					type: 'number',
					min: 0,
					controlsPosition: 'right',
					span: 8,
				},
				{
					label: '服务总次数（单）',
					prop: 'serviceNumber',
					type: 'number',
					min: 0,
					controlsPosition: 'right',
					span: 8,
				},
				{
					label: '备注',
					prop: 'remarks',
					type: 'input',
					span: 8,
				},
			],
		},
	],
}

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '补贴类型名称',
			prop: 'subsidyName',
			type: 'input',
			span: 8,
		},
		{
			label: '是否达标统计',
			prop: 'isStandard',
			type: 'select',
			dicData: [
				{
					label: '是',
					value: 0,
				},
				{
					label: '不是',
					value: 1,
				},
			],
			span: 8,
		},
		{
			label: '状态',
			prop: 'ruleStatus',
			type: 'select',
			dicData: [
				{
					label: '启用',
					value: 0,
				},
				{
					label: '不启用',
					value: 1,
				},
			],
			span: 8,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '补贴类别名称', prop: 'subsidyName' },
		{ label: '补贴金额（元）', prop: 'money' },
		{
			label: '是否达标统计',
			prop: 'isStandard',
			dicData: [
				{
					label: '是',
					value: 0,
				},
				{
					label: '不是',
					value: 1,
				},
			],
			custome: 'tag',
		},
		{
			label: '状态',
			prop: 'ruleStatus',
			dicData: [
				{
					label: '启用',
					value: 0,
					type: 'success',
				},
				{
					label: '不启用',
					value: 1,
					type: 'danger',
				},
			],
			custome: 'tag',
		},
		{ label: '提交人', prop: 'createUserName' },
		{ label: '提交时间', prop: 'createTime' },
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_omSubsidyRule_page',
	add: 'view_omSubsidyRule_add',
	edit: 'view_omSubsidyRule_edit',
	delete: 'view_omSubsidyRule_del',
	detail: 'view_omSubsidyRule_view',
}
export const auth = {
	...api,
}
export const baseConfig = {
	pageName: '补贴类别设置',
	dictcodes: ['ELDERLY_TYPE', 'ACCESS_LEVEL_COUNTRY'],
	rowKey: 'id',
	addLabel: '新增',
	tipLabel: 'subsidyName',
	exportMqTopic: '/ning/export/',
	api,
	auth,
	menuBtn: [
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: auth.edit,
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: auth.delete,
			text: true,
			show: true,
		},
		{
			icon: 'detail',
			label: '详情',
			type: 'primary',
			operate: 'detail',
			auth: auth.index,
			text: true,
			show: true,
		},
	],
	operateFormate: async (row, type) => {
		return new Promise((resolve, reject) => {
			if (row.id) {
				apiMod.view_omSubsidyRule_view(row.id).then((res) => {
					const temp = res.data || {}
					resolve(temp)
				})
				return
			}
			resolve(row)
		})
	},
	saveFormate: async (form) => {
		return new Promise((resolve, reject) => {
			resolve(form)
		})
	},
	onLoadFormate: async (arr) => {
		return new Promise((resolve, reject) => {
			resolve(arr)
		})
	},
	dialogConfig: {
		width: '75%',
	},
	searchConfig,
	formConfig,
	tableConfig,
	detailConfig: formConfig,
}
